import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_my_web/pages/tools/drop_draw_board/base/build_utils.dart';
import 'package:flutter_my_web/widget/AppBarTitleWidget.dart';

class ShowBuildWidget extends StatefulWidget {
  String json;

  ShowBuildWidget(this.json);

  @override
  State<ShowBuildWidget> createState() => _ShowBuildWidgetState();
}

class _ShowBuildWidgetState extends State<ShowBuildWidget> {
  List<Widget> values = [];

  @override
  void initState() {
    super.initState();
    var jsonObj = jsonDecode(widget.json) as List;
    jsonObj.forEach((element) {
      var dropBean = getDropBean(element);
      var widget = buildBaseDropWidgetByType(dropBean) ?? Container();
      values.add(widget);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: AppBarTitleWidget("拖拽画板"),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: values,
        ),
      ),
    );
  }
}
